package com.itheima.service.impl;

import com.alibaba.fastjson.JSON;
import com.itheima.dao.ConfigMapper;
import com.itheima.pojo.WebConfig;
import com.itheima.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


/**
 * @author xuchangshuo
 * @date 2020/8/3 19:22
 */
@Service
public class ConfigServiceImpl implements ConfigService {

    @Autowired
    private ConfigMapper configMapper;

    @Override
    public List<WebConfig> findConfig() {

        List<WebConfig> webConfig = configMapper.selectAll();

        return webConfig;
    }

    @Override
    public void editWebConfig(Map<String,Object> map) {
      map.remove("pageSize");
      map.remove("currentPage");
        String jsonString = JSON.toJSONString(map);
        WebConfig webConfig = JSON.parseObject(jsonString, WebConfig.class);
        int i = configMapper.updateByPrimaryKeySelective(webConfig);
    }
}
